#include "../../hikvision/include/hikvisionDriver.h"
#include "../../cameradrv/include/cameraDrv.h"
#include <stdio.h>


static void initCamera(void)
{
    hikvisionInit();
}


/* app应用程序 */
int main(int argc,char** argv)
{
    /* 初始化摄像头设备 */
    initCamera();

    /* 根据摄像头名称找到设备 */
    pCameraObj myCameraObj;
    myCameraObj = cameraFind("HIKVISION");

#if 0 //PUT请求,写时间参数
    /* 填充自定义参数 */
    TimeSelfPut mytime;
    mytime.time = "2023-02-28T10:50:44+08:00";

    /* 填充请求参数 */
    reqArgs mydata;
    mydata.url = PUT_DEV_TIME;
    mydata.mode = Custom;
    mydata.type = Time;
    mydata.selfPut = &mytime;
    /* 发送请求 */
    int res = cameraWrite(myCameraObj,&mydata);
    if(res == 0)
    {
        printf("request succ.\r\n");
    }
#endif

#if 0 //PUT请求,写OSD参数
    /* 填充自定义参数 */
    OSDSelfPut myosd;
    myosd.name = "瑞华康源办公室";
    /* 填充请求参数 */
    reqArgs mydata;
    mydata.url = PUT_DEV_OSD_NAME;
    mydata.mode = Custom;
    mydata.type = OSD;
    mydata.selfPut = &myosd;
    /* 发送请求 */
    int res = cameraWrite(myCameraObj,&mydata);
    if(res == 0)
    {
        printf("request succ.\r\n");
    }
#endif

#if 0   //GET请求，读设备信息
    reqArgs mydata;
    deviceInfor mydeviceInfor;
    mydata.url = GET_DEVINFO_URL;
    mydata.mode = Custom;
    mydata.type = Infor;
    mydata.getInfo = &mydeviceInfor;
    int res = cameraRead(myCameraObj,&mydata);
    printf("name = %s.\r\n",mydeviceInfor.deviceName);
    printf("id = %s.\r\n",mydeviceInfor.deviceID);
    printf("seri = %s.\r\n",mydeviceInfor.serialNumber);
    printf("mac = %s.\r\n",mydeviceInfor.macAddress);

#endif

#if 0  //GET请求，读时间信息
    reqArgs mydata;
    deviceTime mydeviceTime;
    mydata.url = GET_DEV_TIME_URL;
    mydata.mode = Custom;
    mydata.type = Time;
    mydata.getInfo = &mydeviceTime;
    int res = cameraRead(myCameraObj,&mydata);
    printf("localtime = %s.\r\n",mydeviceTime.localtime);
    printf("timemode = %s.\r\n",mydeviceTime.timemode);
#endif

    return 0;
}